package com.itheima.config;

import com.itheima.interceptor.DemoInterceptor;
import com.itheima.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: zhengsuyang
 * @Desc:
 * @create: 2025-09-12 17:42
 **/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private DemoInterceptor demoInterceptor;
    @Autowired
    private TokenInterceptor tokenInterceptor;
    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(demoInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
        //                                         增加拦截路径               排除拦截路径
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**").excludePathPatterns("/login","/js/**.js","/**.html");
    }
}
